<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <script>
      //依次获取 用户数据 订单数据 商品数据
      function getUser() {
        setTimeout(() => {
          let data = "UserData";
          iterator.next(data);
        }, 1000);
      }

      function getOrder() {
        setTimeout(() => {
          let data = "OrderData";
          iterator.next(data);
        }, 1000);
      }

      function getGoods() {
        setTimeout(() => {
          let data = "GoodsData";
          iterator.next(data);
        }, 1000);
      }

      function* gen() {
        let Userdata = yield getUser();
        console.log(Userdata);
        let Orderdata = yield getOrder();
        console.log(Orderdata);
        let Goodsdata = yield getGoods();
        console.log(Goodsdata);
      }

      let iterator = gen();
      iterator.next();
    </script>
  </body>
</html>
